package com.demo.component;

import com.demo.domain.Dog;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

@Component
public class MyInitBean implements InitializingBean, FactoryBean<Dog> {

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("这是一个 InitializingBean 执行。。。。。");
    }

    @Override
    public Dog getObject() throws Exception {
        System.out.println("MyInitBean 的 getObject() 方法！");
        return new Dog();
    }

    @Override
    public Class<?> getObjectType() {
        return Dog.class;
    }

    @Override
    public boolean isSingleton() {
        return true;
    }
}
